from rest_framework import serializers
from .models import CourseCategory,Course,Teacher
class CourseCategoryModelSerializer(serializers.ModelSerializer):
    '''
    """课程分类的序列化器"""
    '''
    class Meta:
        model = CourseCategory
        fields = ("id","name")

class CourseTeacherModelSerializer(serializers.ModelSerializer):
    """课程所属老师的序列化器"""
    class Meta:
        model = Teacher
        fields = ("name","title","signature")

class CourseModelSerializer(serializers.ModelSerializer):

    """课程信息的序列化器"""
    teacher = CourseTeacherModelSerializer()
    class Meta:
        model = Course
        fields = ("id","name","course_img","students","lessons","pub_lessons","price","teacher","lesson_list")

class CourseDetailTeacherSerializer(serializers.ModelSerializer):
    """课程列表的老师信息"""
    class Meta:
        model = Teacher
        fields = ["id","name","role","title","signature","brief","image"]


class CourseDetailModelSerializer(serializers.ModelSerializer):
    """课程详情信息"""
    teacher = CourseDetailTeacherSerializer()
    class Meta:
        model = Course
        fields = ["id","name","course_img","course_video","students","lessons","pub_lessons","price","teacher","real_brief","level_name", "chapter_list"]